package DTO;

/**
 * This class acts as data transfer abstraction for item object attributes. It encapsulates address attributes.
 * This object is transferred back and forth amongst various layers.
 * @author tejinder
 * @see DTO
 */
public class Item {

    private String upc;
    private String name;
    private double costPrice;
    private double retailPrice;
    private String description;
    private String make;
    private String model;
    private String imgURL;
    private int ctid;
    private int qty;
    private int newQtyInStore;
    private double soldPrice;
    private double storeCardDiscount;
    private double discountAmount;

    /**
     * default constructor
     */
    public Item() {
        upc = "";
        name = "";
        costPrice = 0.00;
        retailPrice = 0.00;
        description = "";
        make = "";
        model = "";
        imgURL = "";
        ctid = 0;
        qty = 0;
        newQtyInStore = 0;
        soldPrice = 0.00;
        storeCardDiscount = 0.00;
        discountAmount = 0.00;
    }

    /**
     * parameterized constructor
     * @param upc a string for item code
     * @param name a string for item name
     * @param make a string for item manufacturer
     * @param model a string for item model
     * @param qty an integer for item quantity
     * @param soldPrice a double for selling price of item 
     */
    public Item(String upc, String name, String make, String model,
            int qty, double soldPrice) {
      this.upc = upc;
      this.name = name;
      this.make = make;
      this.model = model;
      this.qty = qty;
      this.soldPrice = soldPrice;
    }

    /**
     * parameterized constructor
     * @param upc a string for item code
     * @param name a string for item name
     * @param costPrice a double for item cost price
     * @param retailPrice a double for item retail price
     * @param description a string for item description
     * @param make a string for item manufacturer
     * @param model a string for item model
     * @param imgURL a string for path of item image
     * @param ctid an integer for customer id
     */
    public Item(String upc, String name, double costPrice, double retailPrice,
            String description, String make, String model, String imgURL,
            int ctid) {
        this.upc = upc;
        this.name = name;
        this.costPrice = costPrice;
        this.retailPrice = retailPrice;
        this.description = description;
        this.make = make;
        this.model = model;
        this.imgURL = imgURL;
        this.ctid = ctid;
        qty = 0;
        newQtyInStore = 0;
        soldPrice = retailPrice;
        storeCardDiscount = 0.00;
        discountAmount = 0.00;
    }

    /**
     * gets item code
     * @return
     */
    public String getUpc() {
        return upc;
    }

    /**
     *  sets item code
     * @param newUPC
     */
    public void setUPC(String newUPC) {
        this.upc = newUPC;
    }

    /**
     * gets name of item
     * @return
     */
    public String getName() {
        return name;
    }

    /**
     * sets name of item
     * @param newName
     */
    public void setName(String newName) {
        this.name = newName;
    }

    /**
     * gets cost price of item
     * @return
     */
    public double getCostPrice() {
        return costPrice;
    }

    /**
     * sets cost price of item
     * @param price
     */
    public void setCostPrice(double price) {
        this.costPrice = price;
    }

    /**
     * gets retail price of item
     * @return
     */
    public double getRetailPrice() {
        return retailPrice;
    }

    /**
     * sets retail price of item
     * @param price
     */
    public void setRetailPrice(double price) {
        this.retailPrice = price;
    }

    /**
     * gets item description
     * @return
     */
    public String getDescription() {
        return description;
    }

    /**
     * sets item description
     * @param des
     */
    public void setDescription(String des) {
        this.description = des;
    }

    /**
     * gets item manufacturer
     * @return
     */
    public String getMake() {
        return make;
    }

    /**
     * sets item manufacturer
     * @param m
     */
    public void setMake(String m) {
        this.make = m;
    }

    /**
     * gets item model
     * @return
     */
    public String getModel() {
        return model;
    }

    /**
     * sets item model
     * @param m
     */
    public void setModel(String m) {
        this.model = m;
    }

    /**
     * gets item image
     * @return
     */
    public String getImgURL() {
        return imgURL;
    }

    /**
     * sets item image
     * @param m
     */
    public void setImgURL(String m) {
        this.imgURL = m;
    }

    /**
     * gets category id for item
     * @return
     */
    public int getCategoryID() {
        return ctid;
    }

    /**
     * sets category id for item
     * @param ctid
     */
    public void setCategoryID(int ctid) {
        this.ctid = ctid;
    }

    /**
     * toString() method overrides the default behavior of Object class toString() method.
     * @return  a string representing the state of object
     */
    public String toString() {
        String str = "";
        str = name + " - $" + retailPrice + "\n" + description + "\n";
        return str;
    }

    /**
     * sets item quantity
     * @param qty
     */
    public void setQty(int qty) {
        this.qty = qty;
    }

    /**
     * gets item quantity
     * @return
     */
    public int getQty() {
        return qty;
    }

    /**
     * sets quantity
     * @param i
     */
    public void setNewQtyInStore(int i) {
        this.newQtyInStore = i;
    }

    /**
     * gets quantity
     * @return
     */
    public int getNewQtyInStore() {
        return newQtyInStore;
    }

    /**
     * sets item sold price
     * @param price
     */
    public void setSoldPrice(double price) {
        this.soldPrice = price;
    }

    /**
     * gets item sold price
     * @return
     */
    public double getSoldPrice() {
        return soldPrice;
    }

    /**
     * sets item discount amount
     * @param amount
     */
    public void setDiscountAmount(double amount) {
        this.discountAmount = amount;
    }

    /**
     * gets item discount
     * @return
     */
    public double getDiscountAmount() {
        return discountAmount;
    }

    /**
     * sets store card discount
     * @param amount
     */
    public void setStoreCardDiscount(double amount) {
        this.storeCardDiscount = amount;
    }

    /**
     * gets store card discount
     * @return double amount
     */
    public double getStoreCardDiscount() {
        return storeCardDiscount;
    }

    /**
     * this method increments quantity
     */
    public void increaseQty(){
        qty++;
    }

    /**
     *  this method decrements quantity
     */
    public void decreaseQty(){
        if (qty > 1)
            qty--;
    }
}
